package cn.lili.modules.payment.entity.dto;

import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.payment.entity.dos.CombinePaymentLog;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 合单支付查询参数
 *
 * @author liushuai(liushuai711 @ gmail.com)
 * @version v4.0
 * @Description:
 * @since 2023/6/30 15:04
 */
@Data
public class CombineSearchParams extends PageVO {

    @ApiModelProperty(value = "合单支付号码")
    private String orderSn;

    @ApiModelProperty(value = "支付方式")
    private String paymentMethod;

    @ApiModelProperty(value = "客户端类型")
    private String clientType;

    @ApiModelProperty(value = "回查确认状态")
    private Boolean isCheck;

    @ApiModelProperty(value = "支付发起开始时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private String startDate;

    @ApiModelProperty(value = "支付发起结束时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private String endDate;


    public LambdaQueryWrapper<CombinePaymentLog> generateWrapper() {

        LambdaQueryWrapper<CombinePaymentLog> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CharSequenceUtil.isNotEmpty(this.orderSn), CombinePaymentLog::getOrderSn, this.orderSn);
        queryWrapper.eq(CharSequenceUtil.isNotEmpty(this.paymentMethod), CombinePaymentLog::getPaymentMethod, this.paymentMethod);
        queryWrapper.eq(CharSequenceUtil.isNotEmpty(this.clientType), CombinePaymentLog::getPaymentClient, this.clientType);
        queryWrapper.eq(this.isCheck != null, CombinePaymentLog::getIsCheck, this.isCheck);
        queryWrapper.between(this.startDate != null && endDate != null, CombinePaymentLog::getCreateTime, this.startDate, this.endDate);
        return queryWrapper;

    }
}
